CC=c++
CFLAGS=-Wall -std=c++0x

OBJ=Obj
LIBS=$(OBJ)/utf8.o $(OBJ)/log.o $(OBJ)/config.o
DIR=NS
SSOURCE=$(DIR)/ns.rpc_svc.c $(DIR)/ns.rpc.srv.cpp $(DIR)/nameserversrv.cpp
CSOURCE=$(DIR)/ns.rpc_clnt.c $(DIR)/nameserver.cpp
HEADERS=$(DIR)/ns.rpc.h $(DIR)/nameserver.h
SOURCE=$(DIR)/ns.rpc_xdr.c

all: client server

client: $(LIBS) $(SOURCE) $(CSOURCE) $(HEADERS)
	$(CC) $(CFLAGS) $(DIR)/ns.rpc_xdr.c -c -o $(OBJ)/ns-client-xdr.o
	$(CC) $(CFLAGS) $(DIR)/ns.rpc_clnt.c -c -o $(OBJ)/ns-client-rpc.o
	$(CC) $(CFLAGS) $(DIR)/nameserver.cpp -c -o $(OBJ)/ns-client.o

server: $(LIBS) $(SOURCE) $(SSOURCE) $(HEADERS)
	$(CC) $(CFLAGS) $(LIBS) $(OBJ)/ns-client*.o $(SSOURCE) -o Bin/ns-server

test: $(OBJ)/*.o $(DIR)/test.cpp
	$(CC) $(CFLAGS) $(OBJ)/log.o $(OBJ)/config.o $(OBJ)/utf8.o $(OBJ)/ns-client*.o $(DIR)/test.cpp -o Bin/ns-test
